-------------------------------------------------------------------------------------------------------------------------------------

. do "K:\Jan - PACs\2004 Final Submission - April\Data Archive\splitpop.do"

. * To call up the model, issue this command:
. *       ml model lf splitpps (duration: duration = x1 x2 ...) (logit: censor = x1 x2 ...) /shape
. *
. *       To maximize the function, issue the "ml max" command. For more difficult models, use "ml max, difficult". 
. *       For better starting values, issue "ml search" after calling up the model and before maximizing it. 
. 
. program define splitpps
  1.         args lnf theta1 theta2 theta3 
  2.         tempvar p s d l 
  3.         quietly gen double `l'=exp(-`theta1')
  4.         quietly gen double `d'=exp(`theta2')/(1+exp(`theta2'))
  5.         quietly gen double `s'=1- `d' +`d'*(1/(1+(`l'*$ML_y1)^(1/`theta3')))
  6.         quietly gen double `p'=ln(`d')-ln(`theta3')+((1/`theta3')-1)*ln($ML_y1)+(1/`theta3')*ln(`l')-2*ln(1+(`l'*$ML_y1)^(1/`the
> ta3'))
  7.         quietly replace `lnf'=$ML_y2*(`p')+(1-$ML_y2)*ln(`s')
  8. end

** LARGE CORPORATE PACS MODEL **

. ml model lf splitpps (duration: T = energy prestige seniorty dleader rleader republic coc votepct quality pquality bcash lagprecp r
> ecpsqrd stshare homecand dcpac) (logit: gave = energy prestige seniorty dleader rleader republic coc votepct quality pquality bcash
>  lagprecp recpsqrd stshare homecand dcpac) /shape if large==1

. ml search
initial:       log likelihood =     -<inf>  (could not be evaluated)
feasible:      log likelihood =  -254525.6
improve:       log likelihood = -153108.76
rescale:       log likelihood = -151908.82
rescale eq:    log likelihood = -135879.63

. ml max

initial:       log likelihood = -135879.63
rescale:       log likelihood = -133713.51
rescale eq:    log likelihood = -125970.16
Iteration 0:   log likelihood = -125970.16  (not concave)
Iteration 1:   log likelihood =    -122534  (not concave)
Iteration 2:   log likelihood = -121632.89  (not concave)
Iteration 3:   log likelihood =  -121121.5  (not concave)
Iteration 4:   log likelihood = -120885.33  
Iteration 5:   log likelihood = -120488.21  
Iteration 6:   log likelihood = -120078.29  
Iteration 7:   log likelihood = -120067.82  
Iteration 8:   log likelihood = -120067.78  
Iteration 9:   log likelihood = -120067.78  

                                                  Number of obs   =      58254
                                                  Wald chi2(16)   =     659.21
Log likelihood = -120067.78                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
duration     |
      energy |  -.0988755   .0245992    -4.02   0.000     -.147089   -.0506619
    prestige |  -.0325146   .0188447    -1.73   0.084    -.0694495    .0044203
    seniorty |  -.0190301   .1208747    -0.16   0.875    -.2559401    .2178799
     dleader |  -.0738859   .0306708    -2.41   0.016    -.1339995   -.0137723
     rleader |    .014805    .030998     0.48   0.633    -.0459499    .0755598
    republic |   .0191754   .0256757     0.75   0.455    -.0311482    .0694989
         coc |   -.142856   .0507829    -2.81   0.005    -.2423887   -.0433232
     votepct |   .0252601   .0735104     0.34   0.731    -.1188177    .1693378
     quality |   .0875011   .0270181     3.24   0.001     .0345466    .1404557
    pquality |   .0528262   .0422023     1.25   0.211    -.0298888    .1355412
       bcash |   .1797641   .0390986     4.60   0.000     .1031322     .256396
    lagprecp |   -.547431   .0492046   -11.13   0.000    -.6438703   -.4509917
    recpsqrd |   .0916775   .0192112     4.77   0.000     .0540242    .1293307
     stshare |  -.1714344   .0492569    -3.48   0.001    -.2679761   -.0748927
    homecand |  -.1727625   .0385314    -4.48   0.000    -.2482826   -.0972424
       dcpac |   -.219688    .023746    -9.25   0.000    -.2662293   -.1731467
       _cons |   5.940624   .0631441    94.08   0.000     5.816864    6.064384
-------------+----------------------------------------------------------------
logit        |
      energy |   .9044779   .0339996    26.60   0.000     .8378399    .9711159
    prestige |   .3764109   .0241292    15.60   0.000     .3291185    .4237033
    seniorty |   1.189782   .1540933     7.72   0.000     .8877645    1.491799
     dleader |   .6227702    .041095    15.15   0.000     .5422254     .703315
     rleader |   .6500925   .0453526    14.33   0.000      .561203    .7389821
    republic |  -.3800793   .0349019   -10.89   0.000    -.4484858   -.3116728
         coc |   1.464752    .067471    21.71   0.000     1.332511    1.596992
     votepct |  -.6031125   .0992875    -6.07   0.000    -.7977123   -.4085126
     quality |   .2164138   .0351495     6.16   0.000     .1475219    .2853056
    pquality |   .1017287    .054036     1.88   0.060    -.0041798    .2076373
       bcash |  -.0431943    .050902    -0.85   0.396    -.1429605    .0565718
    lagprecp |   1.677046   .0778442    21.54   0.000     1.524474    1.829618
    recpsqrd |  -.0473823   .0452042    -1.05   0.295     -.135981    .0412164
     stshare |   .9596731   .0880093    10.90   0.000      .787178    1.132168
    homecand |   1.188604   .0677514    17.54   0.000     1.055814    1.321394
       dcpac |   .1528158   .0308739     4.95   0.000     .0923042    .2133275
       _cons |  -2.454064    .081698   -30.04   0.000    -2.614189   -2.293938
-------------+----------------------------------------------------------------
shape        |
       _cons |   .5043154   .0045176   111.63   0.000     .4954611    .5131696
------------------------------------------------------------------------------

** NOTE: For ease of interpretation, we switched the signs of the duration coefficients in tables 1 and 2 of the paper. See the paper for interpretation. **


. predict xb_large, eq(logit)

. gen prob_large=exp(xb_large)/(1+exp(xb_large))

. su prob_large if large==1

** MEAN IS ESTIMATED SPLIT **

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
  prob_large |     58254    .2583459    .1476143   .0604108   .9920551

. su gave if large==1

** MEAN IS OBSERVED SPLIT **

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        gave |     58254    .2377691    .4257206          0          1


** SMALL CORPORATE PACS MODEL **

. ml model lf splitpps (duration: T = energy prestige seniorty dleader rleader republic coc votepct quality pquality bcash lagprecp r
> ecpsqrd stshare homecand dcpac) (logit: gave = energy prestige seniorty dleader rleader republic coc votepct quality pquality bcash
>  lagprecp recpsqrd stshare homecand dcpac) /shape if large==0

. ml search
initial:       log likelihood =     -<inf>  (could not be evaluated)
feasible:      log likelihood = -402238.14
improve:       log likelihood = -172996.59
rescale:       log likelihood = -172996.59
rescale eq:    log likelihood = -123816.69

. ml max, difficult

initial:       log likelihood = -123816.69
rescale:       log likelihood = -102630.76
rescale eq:    log likelihood = -102438.51
Iteration 0:   log likelihood = -102438.51  (not concave)
Iteration 1:   log likelihood = -98349.758  (not concave)
Iteration 2:   log likelihood = -97629.479  (not concave)
Iteration 3:   log likelihood = -96428.512  (not concave)
Iteration 4:   log likelihood = -96106.146  (not concave)
Iteration 5:   log likelihood = -94620.361  (not concave)
Iteration 6:   log likelihood = -93666.483  (not concave)
Iteration 7:   log likelihood = -93248.456  (not concave)
Iteration 8:   log likelihood = -92253.833  (not concave)
Iteration 9:   log likelihood = -92227.171  (not concave)
Iteration 10:  log likelihood = -92159.793  (not concave)
Iteration 11:  log likelihood = -92149.428  (not concave)
Iteration 12:  log likelihood = -92056.146  (not concave)
Iteration 13:  log likelihood = -92051.881  (not concave)
Iteration 14:  log likelihood = -92009.209  
Iteration 15:  log likelihood = -91999.271  
Iteration 16:  log likelihood = -91968.383  (not concave)
Iteration 17:  log likelihood = -91858.334  (not concave)
Iteration 18:  log likelihood = -91677.128  
Iteration 19:  log likelihood =  -91449.57  
Iteration 20:  log likelihood = -91279.676  
Iteration 21:  log likelihood = -91261.494  
Iteration 22:  log likelihood = -91261.291  
Iteration 23:  log likelihood = -91261.291  

                                                  Number of obs   =     278502
                                                  Wald chi2(16)   =     265.19
Log likelihood = -91261.291                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
duration     |
      energy |  -.0128554   .0360056    -0.36   0.721    -.0834251    .0577144
    prestige |  -.0205664   .0273579    -0.75   0.452    -.0741869    .0330541
    seniorty |   .0265385   .1766595     0.15   0.881    -.3197078    .3727849
     dleader |  -.0192988   .0460552    -0.42   0.675    -.1095654    .0709677
     rleader |   .0561851   .0451237     1.25   0.213    -.0322556    .1446258
    republic |  -.1585509   .0377644    -4.20   0.000    -.2325679    -.084534
         coc |   .4286935   .0741709     5.78   0.000     .2833212    .5740659
     votepct |  -.6249758    .103557    -6.04   0.000    -.8279439   -.4220078
     quality |    .090469   .0402357     2.25   0.025     .0116085    .1693295
    pquality |   .0516153   .0562884     0.92   0.359    -.0587079    .1619384
       bcash |   .0850244   .0583432     1.46   0.145    -.0293261    .1993749
    lagprecp |  -3.950019   .4418056    -8.94   0.000    -4.815942   -3.084096
    recpsqrd |    9.42433    1.41098     6.68   0.000     6.658861     12.1898
     stshare |   .0875561   .0413185     2.12   0.034     .0065734    .1685389
    homecand |  -.3357594   .0322605   -10.41   0.000    -.3989888   -.2725301
       dcpac |  -.0406849   .0488986    -0.83   0.405    -.1365244    .0551547
       _cons |    6.60631   .0868843    76.04   0.000      6.43602      6.7766
-------------+----------------------------------------------------------------
logit        |
      energy |   .6835162   .0380709    17.95   0.000     .6088986    .7581338
    prestige |   .2380393    .028741     8.28   0.000      .181708    .2943707
    seniorty |   1.217237    .181476     6.71   0.000     .8615507    1.572924
     dleader |   .5188823   .0468977    11.06   0.000     .4269644    .6108001
     rleader |   .4964743   .0495708    10.02   0.000     .3993173    .5936313
    republic |  -.4801116   .0412069   -11.65   0.000    -.5608756   -.3993475
         coc |   1.654939   .0790915    20.92   0.000     1.499922    1.809955
     votepct |  -.4007773   .1122196    -3.57   0.000    -.6207237   -.1808308
     quality |   .2689056   .0428679     6.27   0.000     .1848861    .3529251
    pquality |   .2453865   .0605697     4.05   0.000     .1266721    .3641009
       bcash |  -.1296779   .0606112    -2.14   0.032    -.2484736   -.0108821
    lagprecp |   16.78596   .5226329    32.12   0.000     15.76162     17.8103
    recpsqrd |  -43.45452   2.027684   -21.43   0.000    -47.42871   -39.48033
     stshare |   .4540604   .0555812     8.17   0.000     .3451231    .5629976
    homecand |   2.539134   .0415725    61.08   0.000     2.457653    2.620615
       dcpac |   .9259215   .0500865    18.49   0.000     .8277537    1.024089
       _cons |  -5.113607   .0937041   -54.57   0.000    -5.297263    -4.92995
-------------+----------------------------------------------------------------
shape        |
       _cons |   .5278872   .0070694    74.67   0.000     .5140315    .5417429
------------------------------------------------------------------------------

** NOTE: For ease of interpretation, we switched the signs of the duration coefficients in tables 1 and 2 of the paper. See the paper for interpretation. **


. predict xb_small, eq(logit)

. gen prob_small=exp(xb_small)/(1+exp(xb_small))

. su prob_small if large==0

** MEAN IS ESTIMATED SPLIT **

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
  prob_small |    278502      .03866    .0602827   8.59e-06   .8002836

. su gave if large==0

** MEAN IS OBSERVED SPLIT **

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        gave |    278502    .0310411     .173429          0          1

. log close

-------------------------------------------------------------------------------------------------------------------------------------
